package cn.xopencode.oss.rpc.permission;

import cn.xopencode.common.framework.vo.CommonResult;
import cn.xopencode.common.framework.vo.PageResult;
import cn.xopencode.oss.manager.permission.PositionManager;
import cn.xopencode.oss.rpc.permission.dto.PositionPageDTO;
import cn.xopencode.oss.rpc.permission.dto.PositionUpdateDTO;
import cn.xopencode.oss.rpc.permission.dto.PositionCreateDTO;
import cn.xopencode.oss.rpc.permission.vo.PositionVO;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Collection;
import java.util.List;
import java.util.Set;

import static cn.xopencode.common.framework.vo.CommonResult.success;

/**
* 职务 Rpc 实现类
*/
@DubboService(version = "${dubbo.provider.PositionRpc.version}")
public class PositionRpcImpl implements PositionRpc {

    @Autowired
    private PositionManager PositionManager;

    @Override
    public CommonResult<String> createPosition(PositionCreateDTO createDTO) {
        return success(PositionManager.createPosition(createDTO));
    }

    @Override
    public CommonResult<Boolean> updatePosition(PositionUpdateDTO updateDTO) {
        PositionManager.updatePosition(updateDTO);
        return success(true);
    }

    @Override
    public CommonResult<Boolean> deletePosition(String PositionId) {
        PositionManager.deletePosition(PositionId);
        return success(true);
    }

    @Override
    public CommonResult<PositionVO> getPosition(String PositionId) {
        return success(PositionManager.getPosition(PositionId));
    }

    @Override
    public CommonResult<List<PositionVO>> listAllPositions() {
        return success(PositionManager.listAllPositions());
    }

    @Override
    public CommonResult<List<PositionVO>> listPositions(Collection<String> PositionIds) {
        return success(PositionManager.listPositions(PositionIds));
    }

    @Override
    public CommonResult<PageResult<PositionVO>> pagePosition(PositionPageDTO pageDTO) {
        return success(PositionManager.pagePosition(pageDTO));
    }


}
